package com.fi.common.command;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * 定义一个命令执行的返回结构体
 * */
public class CmdRet {
	private final String TAG=getClass().getSimpleName();
	private String stdout;
	private String stderr;
	private int lastCmdRet=-1;				//一般返回最后一条指令的返回
	private boolean crash=false;			//崩溃
	public CmdRet(){
		
	}
	public String toString(){
		String ret="\n--------------------------------------Cmd Ret info :--------------------------------------\n";
		ret+="stdout : \n"+ stdout +"\n";
		ret+="stderr : \n"+ stderr +"\n";
		ret+="ret   : "+ lastCmdRet +"\n";
		ret+="--------------------------------------Cmd Ret info :--------------------------------------\n";
		return ret;
	}
	/**
	 * 定义是否真正运行失败
	 * */
	public static boolean isExecCrash(CmdRet cmdRet){
		if(cmdRet==null){
			return true;
		}
		if(cmdRet.crash || cmdRet.stdout==null || cmdRet.stderr==null){
			return true;
		}
		return false;
	}
	public String getStdout() {
		return stdout;
	}
	public void setStdout(String stdout) {
		this.stdout = stdout;
	}
	public String getStderr() {
		return stderr;
	}
	public void setStderr(String stderr) {
		this.stderr = stderr;
	}
	public int getLastCmdRet() {
		return lastCmdRet;
	}
	public void setLastCmdRet(int lastCmdRet) {
		this.lastCmdRet = lastCmdRet;
	}

	public boolean isCrash() {
		return crash;
	}

	public void setCrash(boolean crash) {
		this.crash = crash;
	}

}
